package com.xtx.controller;

import com.xtx.result.Result;
import com.xtx.service.AllService;
import com.xtx.service.CategoryService;
import com.xtx.vo.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("/home")
public class AllController {

    @Autowired
    private AllService allService;

    @GetMapping("/hot")
    public Result<List<HomeHotVo>> getHomeHot(){
        List<HomeHotVo> homeHotVoList = allService.getHomeHot();
        log.info("获取首页人气推荐接口");
        return Result.success(homeHotVoList);
    }
    @GetMapping("/banner")
    public Result<List<HomeBannerVo>> getHomeBanner(Integer id){
        List<HomeBannerVo> homeBannerVoList = allService.getHomeBanner(id);
        log.info("获取首页轮播图信息");
        return Result.success(homeBannerVoList);
    }

    /**
     * 获取首页新鲜好物
     * @return
     */
    @GetMapping("/new")
    public Result<List<HomeNewVo>> getHomeNew(){
        List<HomeNewVo> homeNewVoList = allService.getHomeNew();
        log.info("获取首页新鲜好物信息");
        return Result.success(homeNewVoList);
    }

    @GetMapping("/casualLook")
    public Result<List<HomeCasualLookVo>> getCasualLook(){
        List<HomeCasualLookVo> homeCasualLookVoList = allService.getHomeCasualLook();
        log.info("获取首页随便看接口");
        return Result.success(homeCasualLookVoList);
    }
    @GetMapping("/head")
    public Result<List<CategoryHeaderVo>> getCategoryAPI(){
        log.info("获取首页商品头部列表信息");
        List<CategoryHeaderVo> categoryHeaderVoList =allService.getCategoryApi();
        return Result.success(categoryHeaderVoList);
    }
}
